package com.example.votesystem.controller;

import com.example.votesystem.constant.MessageConstant;
import com.example.votesystem.entity.Result;
import com.example.votesystem.utils.FileUploadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.Base64.Decoder;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

//import sun.misc.BASE64Decoder;

@RestController
@RequestMapping("/upload")
public class FileUploadController {
    //新增检查项
    @PostMapping("/uploadImage")
    public Object uploadImage(@RequestParam(value = "file", required = false) MultipartFile file,HttpServletRequest request) throws IOException {
        return FileUploadUtil.uploadFile(file,request);
    }
}